DATS 6103 - INDIVIDUAL PROJECT - 2

ARUSHI KAPOOR

TOPIC

The purpose of this project is to explore the following economic indicators Labor Force, Unemployment Rates, Inflation Rates, Population and GDP Per Capita across the world for the time period, 2015 to 2019.

Historically, inflation and unemployment maintain an inverse relationship. Low levels of unemployment correspond with higher inflation, while high rates of unemployment correspond with lower rates of inflation or even deflation.

I would like to explore whether the same still holds true for nations in the given period. Additionally, if the same does not hold true for some nations, I would like to explore the potential reasons attributing to it.

1. SOURCE OF THE DATA

The required datasets were procured from The World Bank Data website.

For this project, the following datasets have been accessed from the source for analyses -

  1. Labor Force (in thousands) https://data.worldbank.org/indicator/SL.TLF.TOTL.IN
  1. Unemployment, total (% of labor force) https://data.worldbank.org/indicator/SL.UEM.TOTL.ZS
  1. Inflation, consumer prices (annual %) https://data.worldbank.org/indicator/FP.CPI.TOTL.ZG
  1. Population, total (in thousands) https://data.worldbank.org/indicator/SP.POP.TOTL
  1. GDP Per Capita (in current USD) https://data.worldbank.org/indicator/NY.GDP.PCAP.CD

Each of the above datasets consist of approximately 10000 observations.

2. READING, CLEANING & PRE - PROCESSING THE DATASETS

The given datasets were read using pandas software library and the merged into one to form a complete dataset for analyses.

First, a list of criteria was created to drop the irrelvant data points. Then a function was created to clean the datasets, which can be seen below.

In [1]:
# Creating a list of criteria 

not_needed=['East Asia & Pacific','Europe & Central Asia','Latin America & Caribbean','Middle East & North Africa','North America','South Asia','Sub-Saharan Africa', 'High income','Low & middle income','Low income','Lower middle income','Middle income','Upper middle income', 'World','Arab World','Central Europe and the Baltics','Caribbean small states','East Asia & Pacific (excluding high income)',
                 'Early-demographic dividend', 'Europe & Central Asia (excluding high income)', 'Euro area','European Union','Fragile and conflict affected situations', 'Heavily indebted poor countries (HIPC)','IBRD only', 'IDA & IBRD total', 'IDA total','IDA blend','IDA only',
                 'Latin America & Caribbean (excluding high income)', 'Least developed countries: UN classification','Late-demographic dividend','Middle East & North Africa (excluding high income)', 'OECD members','Other small states', 'Pacific island small states', 'Pre-demographic dividend','Post-demographic dividend','Sub-Saharan Africa (excluding high income)','Small states','East Asia & Pacific (IDA & IBRD countries)',
                 'Europe & Central Asia (IDA & IBRD countries)','Latin America & the Caribbean (IDA & IBRD countries)',
                 'Middle East & North Africa (IDA & IBRD countries)','South Asia (IDA & IBRD)',
                 'Sub-Saharan Africa (IDA & IBRD countries)']
In [2]:
# Filtering the data using the given function as per analyses requirements. 

import pandas as pd
def display_relevant(dataset):
    data = pd.read_csv(dataset)
    data = data[['Country Name', 'Country Code', '2015', '2016', '2017', '2018', '2019']]
    data = data.dropna()
    dirty_data = data[data['Country Name'].isin(not_needed)]
    dirty_data_indexed = dirty_data.index
    clean_data=data.drop(dirty_data_indexed)
    return clean_data

Unemployment = display_relevant("Unemployment.csv")
Inflation = display_relevant("Inflation.csv")
Population = display_relevant("Population.csv")
GDP_Capita = display_relevant("GDP_Capita.csv")
Labor_Force = display_relevant("Labor Force.csv")

For analyses, the datasets were converted into a long format and merged together using the given function.

In [3]:
# Reshaping the data using the given function for analyses. 

def display_long(df):
    df_long = pd.melt(df,id_vars=['Country Name', 'Country Code'],var_name='Year', value_name='Value').set_index(['Country Name','Country Code'])
    df_long = df_long.reset_index()
    return df_long

Unemployment_long = display_long(Unemployment)
Inflation_long = display_long(Inflation)
Population_long = display_long(Population)
GDP_Capita_long = display_long(GDP_Capita)
Labor_Force_long = display_long(Labor_Force)

The 'Value' columns were renamed respectively as follows.

In [4]:
# Renaming the 'Value' columns respectively as follows

Unemployment_long.rename(columns={'Value':'Unemployment %'}, inplace=True)
Inflation_long.rename(columns={'Value':'Inflation %'}, inplace=True)
Population_long.rename(columns={'Value':'Population'}, inplace=True)
GDP_Capita_long.rename(columns={'Value':'GDP Per Capita'}, inplace=True)
Labor_Force_long.rename(columns={'Value':'Labor Force'}, inplace=True)

First the long datasets were stored together into a list and then merged together to form the Complete dataset.

In [5]:
# Storing all the dataframes into a list

dfs = [Unemployment_long, Inflation_long, Population_long, GDP_Capita_long, Labor_Force_long]
In [6]:
from functools import reduce

# Merging the datasets together to form one dataset

Complete = reduce(lambda left, right: pd.merge(left, right, on=['Country Name', 'Country Code', 'Year']), dfs)
Complete
Out[6]:
Country Name Country Code Year Unemployment % Inflation % Population GDP Per Capita Labor Force
0 Afghanistan AFG 2015 11.387 -0.661709 34413603.0 578.466353 9176450.0
1 Angola AGO 2015 7.282 -21.531694 27884381.0 4166.979684 11437925.0
2 Albania ALB 2015 17.080 1.896174 2880703.0 3952.801215 1289562.0
3 United Arab Emirates ARE 2015 1.910 4.069966 9262900.0 38663.383810 6600371.0
4 Armenia ARM 2015 18.261 3.731691 2925553.0 3607.296697 1334775.0
... ... ... ... ... ... ... ... ...
710 Vietnam VNM 2019 2.013 2.795824 96462106.0 2715.276036 57364650.0
711 Vanuatu VUT 2019 4.385 2.762520 299882.0 3058.065675 128427.0
712 Samoa WSM 2019 8.359 0.982327 197097.0 4315.920675 53500.0
713 South Africa ZAF 2019 28.181 4.124351 58558270.0 6001.400814 23300226.0
714 Zambia ZMB 2019 11.425 9.150316 17861030.0 1291.343357 7401485.0

715 rows × 8 columns

A new dataset, consisting of Country Names and Codes was downloaded and merged with the Complete dataset for graphing purposes. The new dataset, data.csv was downloaded from datahub.io through the following -

https://datahub.io/JohnSnowLabs/country-and-continent-codes-list#resource-country-and-continent-codes-list_zip

In [7]:
# Importing country codes from the above dataset

Country_Code=pd.read_csv('data.csv')
Country_Code=Country_Code[['Continent_Name', 'Three_Letter_Country_Code']]
Country_Code.head()
Out[7]:
Continent_Name Three_Letter_Country_Code
0 Asia AFG
1 Europe ALB
2 Antarctica ATA
3 Africa DZA
4 Oceania ASM

The final dataset was named data which consists of all the required information needed for visualization purposes.

In [8]:
# Merging the country codes to the Complete dataset

data=pd.merge(Complete, Country_Code, left_on= 'Country Code', right_on= 'Three_Letter_Country_Code', how= 'left')
data = data.drop(labels='Three_Letter_Country_Code', axis=1)
data.head()
Out[8]:
Country Name Country Code Year Unemployment % Inflation % Population GDP Per Capita Labor Force Continent_Name
0 Afghanistan AFG 2015 11.387 -0.661709 34413603.0 578.466353 9176450.0 Asia
1 Angola AGO 2015 7.282 -21.531694 27884381.0 4166.979684 11437925.0 Africa
2 Albania ALB 2015 17.080 1.896174 2880703.0 3952.801215 1289562.0 Europe
3 United Arab Emirates ARE 2015 1.910 4.069966 9262900.0 38663.383810 6600371.0 Asia
4 Armenia ARM 2015 18.261 3.731691 2925553.0 3607.296697 1334775.0 Asia
In [9]:
# Calculating change in unemployment rates over the given time period for analysis use

data['Change in Unemployment Rates'] = data.groupby('Country Name')['Unemployment %'].pct_change(periods=4)
In [10]:
data
Out[10]:
Country Name Country Code Year Unemployment % Inflation % Population GDP Per Capita Labor Force Continent_Name Change in Unemployment Rates
0 Afghanistan AFG 2015 11.387 -0.661709 34413603.0 578.466353 9176450.0 Asia NaN
1 Angola AGO 2015 7.282 -21.531694 27884381.0 4166.979684 11437925.0 Africa NaN
2 Albania ALB 2015 17.080 1.896174 2880703.0 3952.801215 1289562.0 Europe NaN
3 United Arab Emirates ARE 2015 1.910 4.069966 9262900.0 38663.383810 6600371.0 Asia NaN
4 Armenia ARM 2015 18.261 3.731691 2925553.0 3607.296697 1334775.0 Asia NaN
... ... ... ... ... ... ... ... ... ... ...
730 Vietnam VNM 2019 2.013 2.795824 96462106.0 2715.276036 57364650.0 Asia -0.052706
731 Vanuatu VUT 2019 4.385 2.762520 299882.0 3058.065675 128427.0 Oceania -0.039851
732 Samoa WSM 2019 8.359 0.982327 197097.0 4315.920675 53500.0 Oceania -0.034311
733 South Africa ZAF 2019 28.181 4.124351 58558270.0 6001.400814 23300226.0 Africa 0.120250
734 Zambia ZMB 2019 11.425 9.150316 17861030.0 1291.343357 7401485.0 Africa 0.130628

735 rows × 10 columns

3. VISUALIZING THE DATA

In [11]:
# Importing the libraries needed for visualization

import numpy as np
import matplotlib.pyplot as plt
import plotly
import chart_studio.plotly as py
import plotly.graph_objs as go
from plotly.subplots import make_subplots
import plotly.tools as tls
import plotly.express as px
import seaborn as sns
import warnings
warnings.filterwarnings('ignore')
%matplotlib inline
### import plotly.offline as py
### py.init_notebook_mode(connected=True)
In [12]:
py.sign_in('arushik1994', 'jD7AopX1C1xMEwC6gEBH')

1. Unemployment Rates Across The World

In [13]:
# Displaying a world map depicting the change in unemployment rates over the given time period
# Adding title, dimensions, projection and animation requirements for a better visualization 

fig = px.choropleth(data, title="Unemployment Rates Across The World", locations="Country Code", color="Unemployment %", 
                   hover_name="Country Name", animation_frame="Year", range_color=[0, 30], 
                   width=900, height=700, projection='natural earth')
fig.show()

Key Findings

As we play the above visual, we observe a significant increase in unemployment in South Africa, Turkey, Brazil, Sudan and Namibia in the past five years.

We also observe a significant decrease in unemployment in Spain and Greece over the given years.

2. Inflation Rates Across The World

In [14]:
# Displaying a world map depicting the change in unemployment rates over the given time period
# Adding title, dimensions, projection and animation requirements for a better visualization 


fig = px.choropleth(data,  title="Inflation Rates Across The World", locations="Country Code", 
                    color="Inflation %", hover_name="Country Name", animation_frame="Year", 
                    range_color=[-5, 30], width=900, height=700, projection='natural earth')
fig.show()

Key Findings

As we play the above visual, we observe the following -

  1. A significant decrease in inflation in Russia, Ukraine, Kazakhstan and Brazil in the past five years.
  1. A significant increase in inflation in Angola, Turkey and Sudan in the past five years.

3. Exploring relationships among the given economic indicators

3.1. Between Labor Force and Unemployment Rates

In [15]:
# Displaying an animated scatterplot depicting the relationship between labor force and unemployment rate over the given time period

fig = px.scatter(data, x="Labor Force", y="Unemployment %", animation_frame="Year", animation_group="Country Name",
           size="Population", color="Continent_Name", hover_name="Country Name", facet_col="Continent_Name", facet_col_spacing=0.03,
log_x=True, size_max=45)
fig.for_each_annotation(lambda a: a.update(text=a.text.split("=")[-1]))
fig.show()

Key Findings

  1. Across continents, the labor force of most countries has remained consistent over time while the unemployment rates have fluctuated significantly.
  1. In Asia, Armenia is observed to be an outlier over the given time period.
  1. In Africa, South Africa is observed to have the highest unemployment rate in 2015 and 2019.
  1. In Europe, Bosnia and Herzegovina ranks the highest in unemployment rate in 2015, 2016 and 2019. In 2017, Greece took the lead whereas North Macedonia had the highest unemployment rate in 2018.
  1. In Oceania, Australia is observed to have the highest unemployment rate throughout.
  1. In North America, Haiti is observed to have the highest unemployment rate throughout.
  1. In South America, Brazil leads with the highest unemployment rate for the given time period.

3.2 Between Unemployment Rates and Inflation Rates

In [16]:
# Displaying an animated scatterplot depicting the relationship between unemployment rate and inflation rate over the given time period

fig = px.scatter(data, x="Inflation %", y="Unemployment %", animation_frame="Year", animation_group="Country Name",
           size="Population", color="Continent_Name", hover_name="Country Name", facet_col="Continent_Name", facet_col_spacing=0.03, size_max=45, log_x=True)
fig.for_each_annotation(lambda a: a.update(text=a.text.split("=")[-1]))
fig.layout.xaxis.automargin: True 
fig.show()

Key Findings

  1. In Asia, Armenia can be observed as an outlier with the highest unemployment rate as compared to other nations. However, it's inflation rate has been low in the given period.
  1. In Africa, South Africa's unemployment has increased over the given time period. However, its inflation has fallen slightly.
  1. In Europe, Serbia ranked the highest in unemployment in 2015. However, in 2019, Bosnia and Herzegovina ranked the highest in unemployment while Serbia's unemployment rate has fallen significantly.
  1. In Oceania, Australia ranks the highest in both unemployment and inflation over the given time period.
  1. In North America, Haiti ranks the highest among all the nations in the region over the given time period in inflation and unemployment.
  1. In South America, Brazil leads. However, it is interesting to note that the country's inflation has considerably fallen over the given time period while its unemployment has increased significantly.

3.3 Between Unemployment Rates and GDP Per Capita

In [17]:
# Displaying an animated scatterplot depicting the relationship between GDP per capita and unemployment rate over the given time period

fig = px.scatter(data, title = "Relationship between Unemployment Rates and GDP Per Capita", x= "GDP Per Capita", y= "Unemployment %", animation_frame= "Year", 
 animation_group= "Country Name", size= "Population", color = "Continent_Name",
 hover_name= "Country Name", log_x=True, size_max=100)
fig.layout.updatemenus[0].buttons[0].args[1]["frame"]["duration"] = 700
fig.show()
In [ ]:
 

Key Findings

  1. In Asia, Qatar is observed to have the highest GDP Per Capita and the lowest unemployment rate from 2015 to 2019. Singapore ranks the second.
  1. In Africa, Mauritius is observed to have the highest GDP Per Capita in 2016, 2017, 2018 and 2019. Burundi is observed to have the lowest unemployment rates throughout the given time period. However, Burundi also ranks the lowest in GDP Per Capita as compared to other nations in the continent.
  1. In Europe, Switzerland is observed to have the highest GDP Per Capita throughout the given time period. Norway is observed to have the lowest unemployment rate in 2015. However, since 2016, Czech Republic leads with the lowest unemployment rates in the continent. Another striking observation is a steady increase in GDP Per Capita and a steady decrease in unemployment rate in Ireland in the given time period.
  1. In Oceania, Australia leads with the highest GDP Per Capita and unemployment rate as compared to New Zealand and Papua New Guinea.
  1. In North America, GDP Per Capita has steadily increased while unemployment rate has steadily decreased in the United States through the given time period.
  1. In South America, Uruguay leads with the highest GDP Per Capita throughout while Peru leads with the lowest unemployment rate throughout the given time period.

3.4 Between Inflation Rates and GDP Per Capita

In [18]:
# Displaying an animated scatterplot depicting the relationship between GDP per capita and inflation rate over the given time period

fig = px.scatter(data, title = "Relationship between GDP Per Capita and Inflation Rates", x= "GDP Per Capita", y= "Inflation %", animation_frame= "Year", 
 animation_group= "Country Name", size= "Population", color = "Continent_Name",
 hover_name= "Country Name", log_x=True, size_max=100)
fig.layout.updatemenus[0].buttons[0].args[1]["frame"]["duration"] = 700
fig.show()

Key Findings

  1. In Asia, Singapore is observed to have the lowest inflation rate in 2015 and 2016. Qatar overtook Singapore in 2017, 2018 and 2019. In 2018 and 2019, Turkey hit a record high in inflation in Asia.
  1. In Africa, since 2015, Sudan has observed a massive increase in inflation along with a decrease in GDP Per Capita. Compared to other nations, Burundi observed the lowest inflation rate (deflation) in 2018 and 2019.
  1. In Europe, Switzerland is observed to have the lowest inflation rate as compared to other nations for the given time period. Kazakhstan's inflation has been steadily decreasing while it's GDP Per Capita has been increasing since 2017. A striking observation is negativ einflation rates for most European nations in 2015.
  1. In Oceania, though Papua New Guinea's inflation ha sbeen steadily decreasing since 2015, it continues to lead with the highest inflation rate as compared to Australia and New Zealand.
  1. In North America, Haiti's inflation rate has observed a massive increase since 2015.
  1. In South America, Uruguay leads with the highest GDP Per Capita along with the highest inflation rate since 2015.

4. Top 15

4.a. Lowest unemployment rates in each year

In [19]:
# Querying uneployment rates by year, sorting them in an ascending order and storing the same in a list

top15_unemp_2015 = data.query('Year == "2015"').sort_values(by = 'Unemployment %', ascending = True)[:15]
top15_unemp_2016 = data.query('Year == "2016"').sort_values(by = 'Unemployment %', ascending = True)[:15]
top15_unemp_2017 = data.query('Year == "2017"').sort_values(by = 'Unemployment %', ascending = True)[:15]
top15_unemp_2018 = data.query('Year == "2018"').sort_values(by = 'Unemployment %', ascending = True)[:15]
top15_unemp_2019 = data.query('Year == "2019"').sort_values(by = 'Unemployment %', ascending = True)[:15]
In [20]:
# Graphing subplots to show the top 15 countries with lowest unemployment rates for each year
# Making and positioning subplots corresponding to each year using the above created list

fig = make_subplots(rows=3, cols=2, vertical_spacing = 0.30, column_widths=[0.5, 0.5])
fig.add_trace(go.Bar(x=top15_unemp_2015['Country Name'], y=top15_unemp_2015['Unemployment %'], name='2015'), row=1, col=1)
fig.add_trace(go.Bar(x=top15_unemp_2016['Country Name'], y=top15_unemp_2016['Unemployment %'], name='2016'), row=1, col=2)
fig.add_trace(go.Bar(x=top15_unemp_2017['Country Name'], y=top15_unemp_2017['Unemployment %'], name='2017'), row=2, col=1)
fig.add_trace(go.Bar(x=top15_unemp_2018['Country Name'], y=top15_unemp_2018['Unemployment %'], name='2018'), row=2, col=2)
fig.add_trace(go.Bar(x=top15_unemp_2019['Country Name'], y=top15_unemp_2019['Unemployment %'], name='2019'), row=3, col=1)

# Adding dimensions and plot title  

fig.update_layout(height = 800, width=800, title_text= 'Countries with Lowest Unemployment Rates: Top 15')

# Displaying the combined plot 

fig.show()

4.b. Lowest inflation rates in each year

In [21]:
# Querying inflation rates by year, sorting them in an ascending order and storing the same in a list

top15_inf_2015 = data.query('Year == "2015"').sort_values(by = 'Inflation %', ascending = True)[:15]
top15_inf_2016 = data.query('Year == "2016"').sort_values(by = 'Inflation %', ascending = True)[:15]
top15_inf_2017 = data.query('Year == "2017"').sort_values(by = 'Inflation %', ascending = True)[:15]
top15_inf_2018 = data.query('Year == "2018"').sort_values(by = 'Inflation %', ascending = True)[:15]
top15_inf_2019 = data.query('Year == "2019"').sort_values(by = 'Inflation %', ascending = True)[:15]
In [22]:
# Graphing subplots to show the top 15 countries with lowest unemployment rates for each year
# Making and positioning subplots corresponding to each year using the above created lists

fig = make_subplots(rows=3, cols=2, vertical_spacing = 0.30, column_widths=[0.5, 0.5])
fig.add_trace(go.Bar(x=top15_inf_2015['Country Name'], y=top15_inf_2015['Inflation %'], name='2015'), row=1, col=1)
fig.add_trace(go.Bar(x=top15_inf_2016['Country Name'], y=top15_inf_2016['Inflation %'], name='2016'), row=1, col=2)
fig.add_trace(go.Bar(x=top15_inf_2017['Country Name'], y=top15_inf_2017['Inflation %'], name='2017'), row=2, col=1)
fig.add_trace(go.Bar(x=top15_inf_2018['Country Name'], y=top15_inf_2018['Inflation %'], name='2018'), row=2, col=2)
fig.add_trace(go.Bar(x=top15_inf_2019['Country Name'], y=top15_inf_2019['Inflation %'], name='2019'), row=3, col=1)

# Adding dimensions and plot title  

fig.update_layout(height = 800, width = 800, title_text= 'Countries with Lowest Inflation Rates: Top 15')

# Displaying the combined plot 

fig.show()

Key Findings

  1. Based on the above visuals, we observe that several European Union nations have had the lowest inflation rates for the given years.
  1. Qatar has consistently led with the lowest unemployment rates for all the five years. Additionally, Qatar was also ranked as one of the nations with lowest inflation rates in 2017, 2018 and 2019.

4.c. Change in unemployment rates

In [23]:
# Sorting the change in unemployment rates in an ascending order

Change_Unemployment = data.sort_values(by = 'Change in Unemployment Rates', ascending = True)[:15]
In [24]:
# Displaying a bar graph depicting the top 15 countries with the maximum change in unemployment rates over the given time period

fig = px.bar(Change_Unemployment, x="Change in Unemployment Rates", y="Country Name", orientation='h', color = 'Continent_Name', title='Change in Unemployment Rates: Top 15')
fig.show()

Key Findings

  1. Czech Republic has observed the highest decrease in unemployment during the given time period.
  1. In Asia, Qatar is the only country among top 15 countries, to have observed a decrease in unemployment during the given time period.
  1. It is interesting to note that in North America, Jamaica is the only country among top 15 countries, to have observed a decrease in unemployment during the given time period.
  1. In Africa, Ghana is the only country among top 15 countries, to have observed a decrease in unemployment during the given time period.
  1. Overall, most European nations have observed a decline in unemployment rates from 2015 to 2019.

4. EXPLORING QATAR

In this section, a linear regression model has been used to predict Qatar's unemployment rates for the next five years, 2020 to 2024.

In [25]:
# Importing linear model for analysis

from sklearn import linear_model
In [26]:
# Slicing rows relevant for Qatar's unemployment rate predictions

Qatar = data[data['Country Name'] == 'Qatar']
Qatar
Out[26]:
Country Name Country Code Year Unemployment % Inflation % Population GDP Per Capita Labor Force Continent_Name Change in Unemployment Rates
115 Qatar QAT 2015 0.170 1.814077 2565710.0 63039.01655 1952246.0 Asia NaN
262 Qatar QAT 2016 0.150 2.676592 2654374.0 57163.06099 2004463.0 Asia NaN
409 Qatar QAT 2017 0.140 0.394879 2724724.0 61264.39648 2046136.0 Asia NaN
556 Qatar QAT 2018 0.110 0.255815 2781677.0 68793.78444 2085366.0 Asia NaN
703 Qatar QAT 2019 0.091 -0.666641 2832067.0 64781.73320 2124504.0 Asia -0.464706

First, the Year column has been converted to an integer type. X and y columns have been reshaped for modelling purposes.

In [27]:
# Changing the datatype of the Year variable
# Storing the Year and Unemployment Rates in X and y respectively and reshaping for modelling purposes

Qatar_new= Qatar[['Year', 'Unemployment %']]
Qatar_new['Year'] = Qatar_new['Year'].astype('int')
X  = Qatar_new.iloc[:, 0].values.reshape(-1, 1)
y = Qatar_new.iloc[:, 1].values.reshape(-1, 1)

As shown below, a model was fitted and the predicted values have been stored in the "predicted" variable.

In [28]:
# Applying the model

regr = linear_model.LinearRegression()
In [29]:
# Fitting the model

regr.fit(X,y)
Out[29]:
LinearRegression()
In [30]:
# Obtaining the predicted values 

predicted = regr.predict(X)

A plot is drafted to observe the actual and predicted values of the nation's unemployment rates for the given years.

In [31]:
# Creating a plot to observe the actual and predicted values for the given time period

# Setting plot size
fig = plt.figure(figsize=(14,6))
# Setting plot type
plt.scatter(X, y)
# Assigning the color red to the trendline 
plt.plot(X, predicted, color = 'red')
# Assigning tick range on the x-axis
plt.xticks(np.arange(2015, 2020, 1))
# Assigning a label to the x-axis
plt.xlabel("Years")
# Assigning a label to the y-axis
plt.ylabel("Unemployment Rates")
# Assigning a plot title 
plt.title("Qatar's Unemployment Rates: 2015-2019")
Out[31]:
Text(0.5, 1.0, "Qatar's Unemployment Rates: 2015-2019")

A score is calculated to judge the reliability of the model.

In [32]:
# Calculating the score to judge the model's reliability 

regr.score(X, y)
Out[32]:
0.9808847116869527

Now, predictions are made for the next five years as shown below and a plot is drafted.

In [33]:
# Creating a list of the next five years 

years=[2020, 2021, 2022, 2023, 2024]

# Storing the list into an array and reshaping the same

future=np.array(years).reshape(-1, 1)

# Predicting the future unemployment rates 

future_unemployment=regr.predict(future)
In [34]:
# Creating a plot to observe the actual and predicted values for the given time period 

fig=plt.figure(figsize=(14,6))
plt.scatter(X, y, label='Actual')
plt.plot(X, y, color = 'Red')

# Creating a plot to observe the predicted values for the next five years 
plt.scatter(years, future_unemployment, marker='o', label='Forecasted')
plt.xticks(np.arange(2015, 2025, 1))
plt.xlabel("Years")
plt.ylabel("Unemployment Rates")
plt.title("Predicting Qatar's Unemployment Rates for the next 5 years: 2020-2024")
plt.legend()
Out[34]:
<matplotlib.legend.Legend at 0x24964118760>

We follow the above steps to predict the nation's inflation rates for the next five years.

In [35]:
# Changing the datatype of the Year variable
# Storing the Year and Unemployment Rates in X and y respectively and reshaping for modelling purposes

Qatar_new= Qatar[['Year', 'Inflation %']]
Qatar_new['Year'] = Qatar_new['Year'].astype('int')
X  = Qatar_new.iloc[:, 0].values.reshape(-1, 1)
y = Qatar_new.iloc[:, 1].values.reshape(-1, 1)
In [36]:
# Applying the model

regr_inf = linear_model.LinearRegression()
In [37]:
# Fitting the model 

regr_inf.fit(X,y)
Out[37]:
LinearRegression()
In [38]:
# Obtaining the predicted values 

predicted_inf = regr_inf.predict(X)
In [39]:
# Creating a plot to observe the actual and predicted values for the given time period

fig = plt.figure(figsize=(14,6))
plt.scatter(X, y)
plt.plot(X, predicted_inf, color = 'red')
plt.xticks(np.arange(2015, 2020, 1))
plt.xlabel("Years")
plt.ylabel("Infltion Rates")
plt.title("Qatar's Inflation Rates: 2015-2019")
Out[39]:
Text(0.5, 1.0, "Qatar's Inflation Rates: 2015-2019")
In [40]:
# Calculating the score to judge the model's reliability 

regr_inf.score(X, y)
Out[40]:
0.7658199045616377
In [41]:
# Creating a list of the next five years 

years=[2020, 2021, 2022, 2023, 2024]

# Storing the list into an array and reshaping the same

future=np.array(years).reshape(-1, 1)

# Predicting the future unemployment rates 

future_inflationt=regr_inf.predict(future)
In [42]:
# Creating a plot to observe the actual and predicted values for the given time period 

fig=plt.figure(figsize=(14,6))
plt.scatter(X, y, label='Actual')
plt.plot(X, y, color = 'Red')

# Creating a plot to observe the predicted values for the next five years 

plt.scatter(years, future_inflationt, marker='o', label='Forecasted')
plt.xticks(np.arange(2015, 2025, 1))
plt.xlabel("Years")
plt.ylabel("Inflation Rates")
plt.title("Predicting Qatar's Inflation Rates for the next 5 years: 2020-2024")
plt.legend()
Out[42]:
<matplotlib.legend.Legend at 0x24964001970>

To conclude, it can be stated that we can expect both Qatar's unemployment and inflation rates to steadily decline in the future. It is important to note that Qatar's low unemployment rate can be attributed to the following -

  1. Low unemployment amongst expatriate population as most expatriate residence permits are linked to their employment permits. Most expatriates exit the country once they are unemployed.
  1. Recent developments in the oil and gas sector have also created a few employment hubs for both expatriates and citizens.
  1. The country has the capacity to absorb young nationals into public sector jobs, thereby keeping youth unemployment rates lower than the world average.

On the other hand, Qatar's low inflation rate can be attributed to the following -

  1. In 2017, an economic embargo was imposed on Qatar by Middle Eastern countries, such as Saudi Arabia, UAE, Bahrain, Egypt and others. The imposition of economic sanctions further worsened the real estate market.
  1. Falling housing prices are a primary contributor to the country's 2019 consumer price deflation.

5. CONCLUSION

From this analysis, we can conclude that Qatar is a suitable example where low unemployment and deflation co-exist. Research has revealed that a similar trend can be observed in other countries in the Middle East such as Saudi Arabia and United Arab Emirates. Additionally, research has revealed that the coronavirus pandemic has further caused a slump in consumer prices in the Middle East. The average consumer in the region continues to cut expenses and remain frugal.

However, for most countries across continents, we observe that over the given period of time, unemployment rates decreased with an increase in inflation rates.

6. LEARNING PROCESS

The learning process has been both interesting and challenging. The lesson that I have learned is the importance of better visualizations. Through this project, I have become well-versed with the concept of creating effective visualizations using plotly.